
package com.webbei.Backstage.action;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import com.opensymphony.xwork2.ActionSupport;
import com.webbei.Backstage.service.BackstateSer;
import com.webbei.util.FileUtil;

public class UploadCdr extends ActionSupport{
	private BackstateSer bao;
	private String username;
	private String orderid;
	private File swfupload;
	private String fileRealPath;
	private String swfuploadContentType;
	private String swfuploadFileName;
	private String wen;
	private String memo;//卖家备注
	public String execute(){
		System.out.println("uploadCdr....."+memo);
		Long id=Long.parseLong(orderid);
		String path = "/img/resources/webbeiUserInfo/"+username+"/userCDR";
		Map<String,Object>m = null;
		if(swfupload!=null&&swfupload.length()>0){
			  m = new HashMap<String,Object>();
				String oldPath =  bao.getCdrurlByorderid(id);
				System.out.println("oldPath:"+oldPath);
				FileUtil.delete(oldPath);
			
		  
	       String savePath = FileUtil.upload(swfupload, path, swfuploadFileName);
	       System.out.println("savePath:"+savePath);
	       
			//bao.updCDRstateAndinCdrpath(path+ "/" + swfuploadFileName,id);
			m.put("cdr", path+ "/" + swfuploadFileName);
		}else{
			m = new HashMap<String,Object>();
			m.put("cdr",null);
		}
		m.put("orderid",orderid);
		m.put("memo",memo);
		System.out.println(m);
		bao.updateOrderByMap(m);
		return null;
	}
	
	public BackstateSer getBao() {
		return bao;
	}
	public void setBao(BackstateSer bao) {
		this.bao = bao;
	}

	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getOrderid() {
		return orderid;
	}
	public void setOrderid(String orderid) {
		this.orderid = orderid;
	}
	public String getWen() {
		return wen;
	}
	public void setWen(String wen) {
		this.wen = wen;
	}
	public File getSwfupload() {
		return swfupload;
	}
	public void setSwfupload(File swfupload) {
		this.swfupload = swfupload;
	}
	public String getSwfuploadContentType() {
		return swfuploadContentType;
	}
	public void setSwfuploadContentType(String swfuploadContentType) {
		this.swfuploadContentType = swfuploadContentType;
	}
	public String getSwfuploadFileName() {
		return swfuploadFileName;
	}
	public void setSwfuploadFileName(String swfuploadFileName) {
		this.swfuploadFileName = swfuploadFileName;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}
	
   
}
